package com.fenghongzhang.day003;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity implements ImagerLoader.MyListener {
    private Button btn;
    private ImageView img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn = (Button) findViewById(R.id.btn);
        img = (ImageView) findViewById(R.id.img);

        requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE},100);
        //给回调赋值
        ImagerLoader.getInstance().setMyListener(this);
    }

    public void click(View view) {
        //下载
        ImagerLoader.getInstance().loading("http://www.qubaobei.com/ios/cf/uploadfile/132/3/2127.jpg");
    }

    @Override
    public void load(Bitmap bitmap) {
        img.setImageBitmap(bitmap);
    }
}
